package com.pifuke.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.view.View;
import android.widget.TextView;
import cn.o.app.adapter.IItemView;
import cn.o.app.adapter.OAdapter;
import cn.o.app.adapter.OItemView;
import cn.o.app.ui.OImageView;
import cn.skinapp.R;

import com.lidroid.xutils.BitmapUtils;
import com.smiier.skin.net.DoctorTreatmentProjectListTask.DoctorTreatmentProjectItem;
import com.smiier.skin.utils.CommonUtility;

public class KepuZhiliaoProjectListAdapter extends
		OAdapter<DoctorTreatmentProjectItem> {
	protected BitmapUtils mBitmapUtils;

	@Override
	protected void onContainerChanged() {
		mBitmapUtils = new BitmapUtils(getContext());
	}

	@Override
	public IItemView<DoctorTreatmentProjectItem> getItemView() {
		return new TreatmentProjectItemView(getContext());
	}

	class TreatmentProjectItemView extends
			OItemView<DoctorTreatmentProjectItem> {

		public TreatmentProjectItemView(Context context) {
			super(context);
		}

		private OImageView mImage;
		private TextView mTreatmentName;
		private TextView mHospitalName;
		private TextView mHospitalLevel;
		private TextView mTreatmentPrice;
		private TextView mTreatmentOrignPrice;
		TextView mLevel;

		@Override
		public void onCreate() {
			setContentView(R.layout.treatment_item);
			mImage = findViewById(R.id.img_treatment, OImageView.class);
			mTreatmentName = findViewById(R.id.treatment_name, TextView.class);
			mHospitalName = findViewById(R.id.treatment_hospital,
					TextView.class);
			mLevel = findViewById(R.id.treatment_hospital_level, TextView.class);
			mHospitalLevel = findViewById(R.id.treatment_hospital_level,
					TextView.class);
			mTreatmentPrice = findViewById(R.id.treatment_price, TextView.class);
			mTreatmentOrignPrice = findViewById(R.id.treatment_price_orgin,
					TextView.class);

		}

		@Override
		public void onResume() {
			mTreatmentName.setText(mDataProvider.name);
			mHospitalName.setText(mDataProvider.hospital);
			// mHospitalLevel.setText(mDataProvider.);
			boolean hasName = CommonUtility.setHosLevel(mDataProvider.hospital,
					mLevel);
			if (!hasName) {
				mLevel.setVisibility(View.GONE);
			}
			if (mDataProvider.original_price <= 0) {
				mTreatmentOrignPrice.setText("具体价格请咨询医院");
				mTreatmentPrice.setText("");
				mTreatmentPrice.setVisibility(View.GONE);
			} else {
				mTreatmentPrice.setVisibility(View.VISIBLE);
				mTreatmentOrignPrice.getPaint().setFlags(
						Paint.STRIKE_THRU_TEXT_FLAG);
				mTreatmentPrice.setText("￥" + mDataProvider.discount_price);
				mTreatmentOrignPrice
						.setText("￥" + mDataProvider.original_price);
			}
		}

	}
}
